
#from file_processor import FileProcessor

import subprocess
from ..file_processor import FileProcessor
#from file_processor import FileProcessor


class HtmlToMarkdownProcessor(FileProcessor):
    def _process_file(self):
        pandoc_options = self.options.get('pandoc_options', [
            '-f', 'html',
            '-t', 'markdown_strict+pipe_tables+table_captions+yaml_metadata_block'
        ])

        # 在这里可以添加自定义的 HTML 处理逻辑
        # 例如：调整标题级别，处理特定的样式等

        # 将处理后的 HTML 转换为 Markdown
        subprocess.run(['pandoc'] + pandoc_options + [self.input_filepath, '-o', self.output_filepath], check=True)



def  test(arg={}):
    # Usage example
    processor = HtmlToMarkdownProcessor("input.html", "output/converted.md")
    result = processor.process()
    print(result)





if __name__ == "__main__":
    HtmlToMarkdownProcessor.main()



"""
python3 -m document2llm.md.html2md.html_to_markdown -i processed.html -o output/html_converted.md
"""

"""

from document2llm.md.html2md.html_to_markdown import HtmlToMarkdownProcessor

processor = HtmlToMarkdownProcessor("input.html", "output/converted2.md")
result = processor.process()
print(result)
"""

#
